package example.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import example.dao.EmpDao;

@Service
public class EmpService {
	@Autowired
	private EmpDao empDao;
	
	public List getEmpList() {
		return this.empDao.getAllList();
	}
	
	public List searchEmp(Map params) {
		return this.empDao.searchEmp(params);
	}
	
	public Map searchEmpPaging(Map params) {
		return this.empDao.searchEmpPaging(params);
	}
	
	public Map getEmpByEmpno(String empno) {
		List list = this.empDao.getEmpByEmpno(empno);
		if(null != list && list.size() > 0) {
			return (Map)list.get(0);
		}
		return null;
	}
	
	public boolean updateEmp() {
		System.out.println("###################  EmpService: updateEmp()");
		empDao.updateEmpByEmpno2(null);
		return false;
	}
	
	public boolean updateEmpException() {
		System.out.println("###################  EmpService: updateEmpException()");
		empDao.updateEmpByEmpno(null);
		empDao.updateEmpByEmpnoException(null);//测试事务回滚
//		empDao.updateEmpByEmpnoInnerException(null);//dao内部事务回滚
		return false;
	}
}
